package com.wf.controller;

import com.wf.interceptor.annotation.RateLimit;
import com.wf.service.BidsService;
import com.wf.web.base.BaseController;
import com.wf.web.domain.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 投标接口
 * 用于处理与投标相关的HTTP请求
 * @author mpk
 * @since 2024/10/11 10:18:11
 */
@RestController
@RequestMapping("/bids")
public class BidsController extends BaseController {
    // 注入投标服务
    @Autowired
    private BidsService bidsService;

    /**
     * 进行投标操作
     * 该方法通过loanId参数识别贷款项目，并调用服务层方法进行投标操作
     * @param loanId 贷款项目的唯一标识
     * @return 投标操作的结果信息
     */
    @RateLimit
    @GetMapping("/bid/{loanId}/{money}")
    public Result bid(@PathVariable String loanId,@PathVariable String money){

        bidsService.bid(loanId,money);

        return success();
    }

    @GetMapping("/preheat/{loanId}")
    public Result preheat(@PathVariable String loanId){

        bidsService.preheat(loanId);

        return success();
    }

}
